var searchUrl =window.location.href;
		var searchData =searchUrl.split("=");        //截取 url中的“=”,获得“=”后面的参数  
		var searchText =decodeURI(searchData[1]);
		
		var result=JSON.parse(searchText);
		
		
		$("title").html(result.name)
		var vueData={};
		vueData.bs=result.bs;
		vueData.id=result.id;
		vueData.name=result.name;
		vueData.arrList={};
		vueData.num=1;//购买数量
		vueData.price=0;//价格
		vueData.stock=0;//库存
		vueData.totalPrice=0;//总价
		vueData.imageHost=imageHost;
		vueData.isStore=1//是否有店
		vueData.stickStock=0;
		
		vueData.branchDesc=result.branchDesc;
		vueData.branchId=result.branchId;
		vueData.logo=result.logo;
		vueData.address=result.address;
		vueData.schedTel=result.schedTel;
		var app=new Vue({
			el:"#app",
			data:vueData,
			created: function(){
				this.common();
			},
			methods:{
				common:function(){
					if(vueData.bs=='bs'){
						$(".mark-dialog-choiceNums").show();
					}
					var postData={};
					postData.id=vueData.id;//套餐类型
					var url="api/ticket/detail";
					this.ajax.get(url,postData,function(res){
					var result=JSON.parse(res);
					 	vueData.arrList=result.data;
					 	vueData.price=result.data.price;
					 	vueData.stock=result.data.stock;
					 	vueData.totalPrice=result.data.price;
					 	vueData.isStore=result.data.isStore;
					 	//app.ticketstroe();
					 	app.getStock();
					})
				},
				getStock:function(){
					var postData={};
					postData.contentId=vueData.arrList.contentId;
					var url="api/ticket/get/num";
					this.ajax.get(url,postData,function(res){
						var result=JSON.parse(res);
						vueData.stickStock=result.data.storageCnt;
					});
				},
				convert:function(){
					$(".mark-dialog-choiceNums").show();
				},
				buy:function(){
					if(vueData.isStore==1&&vueData.branchId==undefined){
						$.alert("请选择门店");
						return;
					}
					if(vueData.num>vueData.stickStock){
						vueData.num=vueData.stickStock;
						$.alert("库存为："+vueData.stickStock);
						return;
					}
					if(vueData.isStore==1){
					$(".mark-dialog-choiceNums").hide();
					var PopupPayPwd = new $.PopupPayPwd();
					PopupPayPwd.init({
						random: true,
						zIndex: 1001,
						callback: function (pwd) {
							var password = md5(pwd);
							PopupPayPwd.close();
							var postData={};
							postData.id=vueData.id;//套餐id
							postData.num=vueData.num;//套餐数量
							postData.password=password;//密码
							postData.branchDesc=vueData.branchDesc;
							postData.branchId=vueData.branchId;
							postData.logo=vueData.logo;
							postData.address=vueData.address;
							postData.schedTel=vueData.schedTel;
							var url="api/ticket/newadd";
							app.ajax.get(url,postData,function(res){
							var result=JSON.parse(res);
								$(".light-btn-btn").show();
								if(result.code==200){
									$(".mark-dialog").show(100);							
								}else{
									
									$.alert(result.mes);      
								}
								
							})
						},
					});
					}else{
						$(".mark-dialog-choiceNums").hide();
						var PopupPayPwd = new $.PopupPayPwd();
						PopupPayPwd.init({
							random: true,
							zIndex: 1001,
							callback: function (pwd) {
								var password = md5(pwd);
								PopupPayPwd.close();
								var postData={};
								postData.id=vueData.id;//套餐id
								postData.num=vueData.num;//套餐数量
								postData.password=password;//密码
								var url="api/ticket/add";
								app.ajax.get(url,postData,function(res){
								var result=JSON.parse(res);
									$(".light-btn-btn").show();
									if(result.code==200){
										$(".mark-dialog").show(100);							
									}else{
										$.alert(result.mes);      
									}
								})
							},
						});
					}
				},
				/*ticketstroe:function(){//如果没有门店获取第一个门店
					if(data.isStore==1&&data.branchId==""||data.branchId==undefined){
						var postData={};
						postData.id=data.arrList.contentId; 
						postData.total=0;
						postData.persize=1;   
						postData.downloads=0;
						var url="api/ticketstroe/page";
						this.ajax.get(url,postData,function(res){
							var result=JSON.parse(res);
							data.branchDesc=result.data.varList[0].branchDesc;
							data.branchId=result.data.varList[0].branchId;
							data.logo=result.data.varList[0].logo;
							data.address=result.data.varList[0].address;
							data.schedTel=result.data.varList[0].schedTel;
						});
					}
				},*/
				goStore:function(id,tickid,name){
					var list={};
					list.id=vueData.id;
					list.tickid=vueData.arrList.contentId;
					list.name=name;
					var val=JSON.stringify(list);
				    var searchText= jQuery.trim(val);  
					var searchUrl=encodeURI("pickStore.html?searchText="+searchText);
					window.location.href =searchUrl;
				},
				add:function(){
					if(vueData.num<vueData.stickStock){
						vueData.num++;
					}else{
						vueData.num=vueData.stickStock;
						$.alert("库存为："+vueData.stickStock);
						return;
					}
					vueData.totalPrice=vueData.num*vueData.price;
				},
				del:function(){
					if(vueData.num>vueData.stickStock){
						vueData.num=vueData.stickStock;
						$.alert("库存为："+vueData.stickStock);
						return;
					}
					if(vueData.num<=1){
						vueData.num=1;
					}else{
						vueData.num--						
					}
					vueData.totalPrice=vueData.num*vueData.price
				},
				closeMark:function(){
					$(".mark-dialog").hide(100);
					window.location.href="detailList.html"
				},
				close:function(){
					$(".mark-dialog-choiceNums").hide(100)
				},
			},
			filters : {
				numberFormat : function(value) {
					return value.toFixed(2);
				}
			}
		})